package com.mlyol.singleton;

public class Demo5 {

    public static void main(String[] args) {
        Demo5 instance1 = Demo5.getInstance();
        Demo5 instance2 = Demo5.getInstance();
        System.out.println(instance1==instance2);
    }

    private Demo5() {

    }

    private static Demo5 instance;

    public static Demo5 getInstance() {
        if (instance == null) {
            synchronized (Demo5.class) {
                instance = new Demo5();
            }
        }
        return instance;
    }


}
